using UnityEngine;
using UnityEngine.EventSystems;

/// <summary>处理按钮按下和释放类</summary>
public class ButtonDownUp : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
    public delegate void PointerDownCallback(); //按下时委托
    public event PointerDownCallback onPointerDown;//按下时事件
    public delegate void PointerUpCallback(); //松开时委托
    public event PointerUpCallback onPointerUp;//松开时事件

    /// <summary>按下时的方法</summary>
    public void OnPointerDown(PointerEventData eventData)
    {
        onPointerDown?.Invoke();//调用方法
    }

    /// <summary>松开时的方法</summary>
    public void OnPointerUp(PointerEventData eventData)
    {
        onPointerUp?.Invoke(); //调用方法
    }
}